{template 'common/header'}

<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('api',array('op' =>'display'))}">渠道管理</a></li>
	<li{if empty($adv['id']) && $operation == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl('api',array('op' =>'post'))}">添加渠道</a></li>
</ul>

{if $operation == 'display'}
<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{php echo $this->modulename}" />
				<input type="hidden" name="do" value="api" />
				

				<div class="form-group">
					<label class="col-xs-12 col-sm-1 control-label">渠道搜索</label>
					<div class="col-sm-2 col-xs-12">
						<input class="form-control" name="keyword2" id="" type="text" value="{$_GPC['keyword2']}" placeholder="请输入关键词">
					</div>
					<div class="col-sm-2 col-xs-12">

                        <select name="keyword1" class="form-control">

						    <option value="" >全部</option>

                            <option value="meituan" >美团</option>

                            <option value="movie" >电影票</option>

                        </select>

                    </div>
					<div class="col-sm-5">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button type="button" class="btn btn-default">总记录数：{$total}</button>
					</div>
				</div>
			</form>
		</div>
</div>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<form action="" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:10%;">排序</th>
					<th>渠道类型</th>
					<th>渠道方姓名</th>
					<th>渠道方电话</th>
					<th>美团渠道标识</th>
					<th>美团结算比例</th>
					<th>电影票平台id</th>
					<th>电影票渠道id</th>
					<th>电影票结算比例</th>
					<th>账户余额</th>
					<th>渠道状态</th>
					<th style="text-align:right;width:15%;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $adv}
				<tr>
					<td><input class="form-control" name="displayorder[{$adv['id']}]" value="{$adv['displayorder']}" type="text"></td>
					<td>
						<div>{if $adv['type']==1}美团{/if}{if $adv['type']==2}电影票{/if}</div>
					</td>
					<td>{$adv['realname']}</td>
					<td>{$adv['mobile']}</td>
					<td>{$adv['meituan_name']}</td>
					<td>{$adv['meituan_rate']}</td>
					<td>{$adv['movie_platformId']}</td>
					<td>{$adv['movie_subplatformId']}</td>
					<td>{$adv['movie_rate']}</td>
					<td>{$adv['money']}</td>
					<td>{if $adv['status']==0}关闭{else}开通{/if}</td>
					<td style="text-align:right;">
					    <a href="{php echo $this->createWebUrl('api', array('op' => 'show', 'id' => $adv['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="{if $adv['status'] == 1}开通{/if}">{if $adv['status'] == 1}关闭{/if}{if $adv['status'] == 0}开通{/if}</a>
						<a href="{php echo $this->createWebUrl('api', array('op' => 'post', 'id' => $adv['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="{php echo $this->createWebUrl('api', array('op' => 'delete', 'id' => $adv['id']))}"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}
				<tr>
					<td colspan="6">
						<input name="submit" class="btn btn-primary" value="提交" type="submit">
						<input name="token" value="{$_W['token']}" type="hidden">
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{elseif $operation == 'post'}

<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="{$adv['id']}" />
		<div class="panel panel-default">
			<div class="panel-heading">
				渠道设置
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[displayorder]" class="form-control" value="{$adv['displayorder']}" />
						<span class="help-block">降序</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">API平台ID：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='uniacid' name="data[uniacid]" class="form-control" value="{$adv['uniacid']}" />
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">API对接秘钥：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='uniacid' name="data[apisecret]" class="form-control" value="{$adv['apisecret']}" />
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">渠道类型：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[type]" value="1" {if $adv['type'] == 1}checked="true"{/if} /> 美团联盟</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[type]" value="2" {if $adv['type'] == 2}checked="true"{/if} /> 千猪电影票</label>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">渠道姓名：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='realname' name="data[realname]" class="form-control" value="{$adv['realname']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">渠道电话：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='mobile' name="data[mobile]" class="form-control" value="{$adv['mobile']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">渠道支付宝账号：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='alipayno' name="data[alipayno]" class="form-control" value="{$adv['alipayno']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">美团官方api秘钥：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='meituan_apikey' name="data[meituan_apikey]" class="form-control" value="{$adv['meituan_apikey']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">美团官方媒体Appkey：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='meituan_appkey' name="data[meituan_appkey]" class="form-control" value="{$adv['meituan_appkey']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">美团官方渠道标识：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='meituan_name' name="data[meituan_name]" class="form-control" value="{$adv['meituan_name']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">美团结算比例：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='meituan_rate' name="data[meituan_rate]" class="form-control" value="{$adv['meituan_rate']}" />
						<span class="help-block" style="color:red;">*请填写数字，填写80，即表示100元佣金，结算80元给渠道方。</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">电影票平台id：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='movie_platformId' name="data[movie_platformId]" class="form-control" value="{$adv['movie_platformId']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">电影票接口秘钥：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='meituan_secret' name="data[movie_secret]" class="form-control" value="{$adv['movie_secret']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">电影票渠道id：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='movie_subplatformId' name="data[movie_subplatformId]" class="form-control" value="{$adv['movie_subplatformId']}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">电影票结算比例：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='movie_rate' name="data[movie_rate]" class="form-control" value="{$adv['movie_rate']}" />
						<span class="help-block" style="color:red;">*请填写数字，填写80，即表示100元佣金，结算80元给渠道方。</span>
					</div>
				</div>
				<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">渠道状态：</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="data[status]" value="0" {if $adv['status'] == 0}checked="true"{/if} /> 关闭</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[status]" value="1" {if $adv['status'] == 1}checked="true"{/if} /> 开通</label>
						</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
</div>

{/if}
{template 'common/footer'}